package com.shelpe.services.sinbad.service.simbaproxy;

import java.util.Date;
import java.util.List;

import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonFormat.Shape;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.shelpe.services.sinbad.entity.jpa.vo.PlatformVo.Channels;

import lombok.Getter;
import lombok.Setter;

@FeignClient(name = "${feign.simba.name}", url = "${feign.simba.url}")
@RequestMapping(value = "/simba")
public interface CampaignClient {

	@RequestMapping(method = RequestMethod.GET, value = "/taobao.simba.campaign.add")
	CreateCampaignResponse createCampaign(@RequestParam("nick") String nick, @RequestParam("title") String title);

	
	@Getter
	@Setter
	public static class CreateCampaignResponse extends SimbaProxyBaseDto {
		@JsonProperty("simba_campaign_add_response")
		private CreateCampaignRes res;
	}

	@Getter
	@Setter
	public static class CreateCampaignRes {
		private CampaignDto campaign;
	}

	@Getter
	@Setter
	public static class CampaignDto {
		private String nick;
		@JsonProperty("campaign_id")
		private long campaignID;
		@JsonProperty("online_status")
		private String onlineStatus;
		@JsonProperty("settle_status")
		private String settleStatus;
		@JsonProperty("settle_reason")
		private String settleReason;
		private String title;

		@JsonProperty("modified_time")
		@JsonFormat(shape = Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
		private Date modifiedTime;
		@JsonProperty("create_time")
		@JsonFormat(shape = Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss")
		private Date createTime;
	}

	@RequestMapping(method = RequestMethod.GET, value = "/taobao.simba.campaign.budget.get")
	CampaignBudgetResponse findCampaignBudget(@RequestParam("nick") String nick,
			@RequestParam("campaign_id") long campaign_id);

	@Getter
	@Setter
	public static class CampaignBudgetResponse extends SimbaProxyBaseDto {
		@JsonProperty("simba_campaign_budget_get_response")
		private CampaignBudgeRes res;
	}

	@Getter
	@Setter
	public static class CampaignBudgeRes {
		@JsonProperty("campaign_budget")
		private CampaignBudgetDto budget;
	}

	@Getter
	@Setter
	public static class CampaignBudgetDto {
		private String nick;
		@JsonProperty("campaign_id")
		private long campaignID;
		private int budget;
		@JsonProperty("is_smooth")
		private boolean useSmooth;
	}

	@Getter
	@Setter
	public static class UpdateCampaignBudgetResponse extends SimbaProxyBaseDto {
		@JsonProperty("simba_campaign_budget_update_response")
		private CampaignBudgeRes res;
	}

	@RequestMapping(method = RequestMethod.GET, value = "/taobao.simba.campaign.budget.update")
	UpdateCampaignBudgetResponse updateCampaignBudget(@RequestParam("nick") String nick,
			@RequestParam("campaign_id") long campaign_id, @RequestParam("budget") long budget,
			@RequestParam("use_smooth") boolean useSmooth);

	@RequestMapping(method = RequestMethod.GET, value = "taobao.simba.campaign.area.get")
	CampaignAreaResponse findCampaignArea(@RequestParam("nick") String nick,
			@RequestParam("campaign_id") long campaign_id);

	@Getter
	@Setter
	public static class CampaignAreaResponse extends SimbaProxyBaseDto {
		@JsonProperty("simba_campaign_area_update_response")
		private CampaignAreaRes res;
	}

	@Getter
	@Setter
	public static class CampaignAreaRes {
		@JsonProperty("campaign_area")
		private CampaignAreaDto area;
	}

	@Getter
	@Setter
	public static class CampaignAreaDto {
		private String nick;
		@JsonProperty("campaign_id")
		private long campaignID;
		private String area; // 值为：“all”；或者用“,”分割的数字，数字必须是直通车全国省市列表的AreaID，如果已经包含省、自治区id，请不要再包括省内市的id；
	}

	@Getter
	@Setter
	public static class UpdateCampaignAreaResponse extends SimbaProxyBaseDto {
		@JsonProperty("simba_campaign_area_update_response")
		private CampaignAreaRes res;
	}

	@RequestMapping(method = RequestMethod.GET, value = "taobao.simba.campaign.area.update")
	UpdateCampaignAreaResponse updateCampaignArea(@RequestParam("nick") String nick,
			@RequestParam("campaign_id") long campaign_id, @RequestParam("area") String area);

	@RequestMapping(method = RequestMethod.GET, value = "taobao.simba.campaign.schedule.get")
	CampaignScheduleResponse findCampaignSchedule(@RequestParam("nick") String nick,
			@RequestParam("campaign_id") long campaign_id);

	@Getter
	@Setter
	public static class CampaignScheduleResponse extends SimbaProxyBaseDto {
		@JsonProperty("simba_campaign_schedule_update_response")
		private CampaignScheduleRes res;
	}

	@Getter
	@Setter
	public static class CampaignScheduleRes {
		@JsonProperty("campaign_schedule")
		private CampaignScheduleDto schedule;
	}

	@Getter
	@Setter
	public static class CampaignScheduleDto {
		private String nick;
		@JsonProperty("campaign_id")
		private long campaignID;
		private String schedule; // 值为：“all”；或者用“;”分割的每天的设置字符串，该字符串为用“,”分割的时段折扣字符串，格式为：起始时间-结束时间:折扣，其中时间是24小时格式记录，折扣是1-150整数，表示折扣百分比；
	}

	@Getter
	@Setter
	public static class UpdateCampaignScheduleResponse extends SimbaProxyBaseDto {
		@JsonProperty("simba_campaign_schedule_update_response")
		private CampaignScheduleRes res;
	}

	@RequestMapping(method = RequestMethod.GET, value = "taobao.simba.campaign.schedule.update")
	UpdateCampaignScheduleResponse updateCampaignSchedule(@RequestParam("nick") String nick,

			@RequestParam("campaign_id") long campaign_id, @RequestParam("schedule") String schedule);

	@RequestMapping(method = RequestMethod.GET, value = "taobao.simba.campaign.platform.get")
	CampaignPlatformResponse findCampaignPlatform(@RequestParam("nick") String nick,
			@RequestParam("campaign_id") long campaign_id);

	@Getter
	@Setter
	public static class CampaignPlatformResponse extends SimbaProxyBaseDto{
		@JsonProperty("simba_campaign_platform_get_response")
		private CampaignPlatformRes res;

	}

	@Getter
	@Setter
	public static class CampaignPlatformRes extends SimbaProxyBaseDto{
		@JsonProperty("campaign_platform")
		private CampaignPlatformDto platform;
	}

	@Getter
	@Setter
	public static class CampaignPlatformDto {
		private String nick;
		@JsonProperty("campaign_id")
		private long campaignID;
		@JsonProperty("outside_discount")
		private int outsideDiscount;// 溢价的百分比，必须是大于等于 1小于等于200的整数
		@JsonProperty("mobile_discount")
		private int mobileDiscount;// 无线折扣百分比。必须大于等于1，小于等于200的整数
		@JsonProperty("search_channels")
		private Channels searchChannels;// 搜索投放频道代码数组，频道代码必须是直通车搜索类频道列表中的值。
		@JsonProperty("nonsearch_channels")
		private Channels nonsearchChannels;// 非搜索投放频道代码数组，频道代码必须是直通车非搜索类频道列表中的值。？
	}
	
	@RequestMapping(method = RequestMethod.GET, value = "taobao.simba.campaign.platform.update")
	UpdateCampaignPlatformResponse updateCampaignPlatform(@RequestParam("nick") String nick,
			@RequestParam("campaign_id") long campaign_id,
			@RequestParam("search_channels") List<Integer> searchChannels,
			@RequestParam("outside_discount") int outsideDiscount, @RequestParam("mobile_discount") int mobileDiscount);

	@Getter
	@Setter
	public static class UpdateCampaignPlatformResponse extends SimbaProxyBaseDto {
		@JsonProperty("simba_campaign_platform_update_response")
		private CampaignPlatformRes res;
	}

	@RequestMapping(method = RequestMethod.GET, value = "taobao.simba.campaign.channeloptions.get")
	CampaignChanneloptionsResponse findChanneloptions();

	@Getter
	@Setter
	public static class CampaignChanneloptionsResponse extends SimbaProxyBaseDto{
		@JsonProperty("simba_campaign_channeloptions_get_response")
		private CampaignChanneloptionsRes res;
	}

	@Getter
	@Setter
	public static class CampaignChanneloptionsRes extends SimbaProxyBaseDto{
		@JsonProperty("channel_options")
		private CampaignChanneloptionsdto channeloptions;
	}

	@Getter
	@Setter
	public static class CampaignChanneloptionsdto {
		@JsonProperty("channel_id")
		private int channelID;
		private String name;
		@JsonProperty("traffic_type")
		private String trafficType;
		@JsonProperty(" traffic_name")
		private String trafficName;
		@JsonProperty("is_search")
		private Boolean useSearch;
		@JsonProperty("is_nonsearch")
		private Boolean useNonSearch;
	}

}